<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<% String path = request.getContextPath();%>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>等你回家</title>
    <!-- Favicon -->
    <link href="<%=path %>/web/index/css/style.css" rel="stylesheet" type="text/css" media="all" />
    <link rel="icon" href="<%=path%>/web/static/images/favicon.png" type="image/png" sizes="32x32">
    <link href="<%=path%>/web/index/css/inc.css" rel="stylesheet" type="text/css" media="all" />

    <!-- All CSS -->
    <link rel="stylesheet" href="<%=path%>/web/static/css/bootstrap.min.css">
    <link rel="stylesheet" href="<%=path%>/web/static/css/style.css">
    <!-- Google font -->
</head>

<body>
<!--header-start -->
<div class="banner-in1">
    <div class="container1">
        <c:if test="${param.lostTypeId eq 3}">
            <h6>寻亲登记 / <span>流浪乞讨</span></h6>
        </c:if>
        <c:if test="${param.lostTypeId eq 4}">
            <h6>寻亲登记 / <span>其他寻家</span></h6>
        </c:if>
        <c:if test="${param.lostTypeId eq 5}">
            <h6>寻亲登记 / <span>游子归家</span></h6>
        </c:if>
    </div>
</div>
<!--header-->
<div class="header1">
    <div class="container1">
        <div class="logo1">
            <a href="index.html"><img src="<%=path %>/web/index/images/logo.png" alt=" " /></a>
        </div>
        <div class="top-nav1">
            <span class="menu1"> </span>
            <ul>
                <li class="active" ><a href="${pageContext.request.contextPath}/web/index" class="scroll">首页</a></li>
                <li><a href="<%=path %>/web/information/chooseType" class="scroll">你在哪儿</a></li>
                <li><a href="<%=path %>/web/information/informationList?lostTypeId=0" class="scroll">我想回家</a></li>
                <li><a href="<%=path %>/web/blogger/blog" class="scroll">日志论坛</a></li>
                <li><a href="<%=path %>/web/task/releaseTask" class="scroll">任务列表</a></li>
                <c:if test="${empty(sessionScope.userinfo)}" var="result">
                    <li><a href="<%=path %>/web/userinfo/register" class="scroll">注册</a>|<a href="<%=path %>/web/userinfo/login" class="scroll">登录</a></li>
                </c:if>
                <c:if test="${not result}">
                    <li><a href="<%=path%>/web/userinfo/applyVolunteer" class="scroll">加入我们</a></li>
                    <c:if test="${(sessionScope.userinfo.username eq '')||(sessionScope.userinfo.username eq NULL)}" var="result">
                        <span style="color:white">欢迎<a href="<%=path %>/web/userinfo/index" style="color: white" href="">${sessionScope.userinfo.phone}</a></span>
                    </c:if>
                    <c:if test="${not result}">
                        <span style="color:white">欢迎<a href="<%=path %>/web/userinfo/index" style="color: white" href="">${sessionScope.userinfo.username}</a></span>
                    </c:if>
                    <span style="color: white">|</span>

                    <span style="color:white"><a style="color: white" href="<%=path %>/web/userinfo/logout">注销</a></span>
                    <span style="color: white">|</span>
                    <label><img style="width:30px;height: 30px" src="<%=path %>/web/uploadImages/${sessionScope.userinfo.pic}"></label>
                </c:if>
            </ul>

        </div>
        <div class="clearfix1"> </div>
    </div>
</div>



<main class="main-content-area clearfix">
    <div class="post-job-area pb-100 pt-100">
        <div class="container">
            <div class="row">
                <div class="col-md-12">
                    <div class="lost-type post-form form-bg" style="border-bottom: #979797 1px solid;">
                        <ul>
                            <li>1.选择登记类型</li>
                            <li class="select">2.填写信息登记</li>
                            <li>3.完成登记</li>
                        </ul>
                    </div>
                    <div class=" post-form form-bg">
                        <div class="info-title mb-3">
                            <h3>求助者信息<span style="color: red;">(*为必填项)</span></h3>
                        </div>

                        <div class="row">
                            <div class="col-md-12">

                                <c:if test="${empty requestScope.information}" var="result">
                                    <form id="form" action="<%=path%>/web/information/findVolunteer" method="post" enctype="multipart/form-data">
                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label for="jobname">&nbsp;求助者姓名</label>
                                            <input type="text" name="name" class="#" id="jobname" value="">
                                            <input type="hidden" name="lostTypeId" value="${param.lostTypeId}"/>
                                            <input type="hidden" value="${sessionScope.userinfo.id}" name="userinfoId"/>
                                            <span id="nameStyle"></span>
                                        </div>
                                    </div>
                                   <%-- <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label for="jobname">联系人姓名</label>
                                            <input type="text" name="name" class="#" id="contactName" value="">
                                            <span id="contactNames"></span>
                                        </div>
                                    </div>--%>

                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label for="jobname"><span style="color: red;">*</span>求助者身高</label>
                                            <input type="text" id="high" name="lostHeight">（cm）
                                            <span style="color:red;" id="highs"></span>
                                        </div>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label for="jobname"><span style="color: red;">*</span>求助者体重</label>
                                            <input type="text" id="weight" name="lostWeight">（kg）
                                            <span style="color:red;" id="weights"></span>
                                        </div>
                                    </div>
                                    <div class="form-row">
                                        <div  class="form-group col-md-12">
                                            <label style="float: left;"><span style="color: red;">*</span>年龄范围</label>
                                            <select id="ageStart"  class="form-control custom-select" style="width:60px;margin-left: 10px; " name="ageStart">
                                                <c:forEach begin="1" end="100" varStatus="stat">
                                                    <option>${stat.index}</option>
                                                </c:forEach>
                                            </select>
                                            <span style="position: absolute;left:158px;">到</span>
                                            <select id="ageEnd" class="form-control custom-select" style="width:60px;margin-left: 10px; " name="ageEnd">
                                                <c:forEach begin="1" end="100" varStatus="stat">
                                                    <option>${stat.index}</option>
                                                </c:forEach>
                                            </select>
                                            <span id="ages" style="position: absolute;left:250px;">（知道具体年龄请前后一致）</span>
                                        </div>

                                    </div>
                                    <div class="form-row" style="margin-top: 0px;">
                                        <div>
                                            <div class="form-group col-md-12">
                                                <label style="margin-left: -10px;" ><span style="color: red;">*</span>发现时间</label>
                                                <input type="date" id="begindate" name="lostDateStart">
                                                <span id="begindates"></span>
                                            </div>
                                        </div>

                                    </div>

                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label for="jobname"><span style="color: red;">*</span>选择性别</label>
                                            <INPUT checked name="sex" type="radio" value="男"/>男
                                            <INPUT name="sex" type="radio" value="女"/>女
                                        </div>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label for="jobname">&nbsp;选择血型</label>
                                            <INPUT name="blood" type="radio" value="A"/>A型
                                            <INPUT name="blood" type="radio" value="B"/>B型
                                            <INPUT name="blood" type="radio" value="AB"/>AB型
                                            <INPUT name="blood" type="radio" value="O"/>O型
                                            <INPUT name="blood" type="radio" value="其它"/>其它
                                        </div>
                                    </div>
                                    <div class="form-row">
                                    <div class="form-group col-md-12">
                                        <label style="float: left; " for="jobname"><span style="color: red;">*</span>上传图片</label>
                                        <input style="float: left;padding-left: 5px;" type="file" id="pic" name="photo"/>
                                        <span id="pics"></span>
                                    </div>
                                    </div>
                                        <!-- 显示图片的DIV-->
                                        <div style="border:1px solid black; width: 250px;height:200px;margin-bottom: 10px;">
                                            <img style="width: 248px;height: 198px;" id="showPic" >
                                        </div>
                                        <!-- /显示图片的DIV-->
                                    <div class="form-row">
                                        <div  class="form-group col-md-12">
                                            <label style="float: left;">&nbsp;籍贯</label>
                                            <select id="province" class="form-control custom-select" style="width:150px;float: left;margin-left: 10px; " name="provinceId">
                                                <c:forEach items="${requestScope.root}" var="area">
                                                    <option value="${area.areaId}">${area.areaName}</option>
                                                </c:forEach>
                                            </select>
                                            <select data-id="0" id="city" name="cityId " class="form-control custom-select" style="width:150px; float: left;">
                                            </select>
                                            <select data-id="0" id="area" name="areaId" class="form-control custom-select" style="width:150px;float: left ">
                                            </select>
                                            <p style="float: left;">(未知可选不详)</p>
                                        </div>
                                    </div>

                                    <div class="form-row">
                                        <label>&nbsp;现居地</label>
                                        <textarea  name="presentAddress"class="form-control" id="jobDescription" rows="3"></textarea>
                                        <span style="color: red" id="live"></span>
                                    </div>
                                    <div class="form-row">
                                        <label >&nbsp;发现地点</label>
                                        <textarea name="findPlace" class="form-control" id="lostPlace" rows="3"></textarea>
                                        <span style="color: red" id="lostplaces"></span>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label for="jobDescription">&nbsp;备注(其他需要填写的信息)</label>
                                            <textarea name="lostRemark" class="form-control" id="jobDescription1" rows="3"></textarea>
                                            <span id="family"></span>
                                        </div>
                                    </div>
                                    <div class="info-title mb-3">
                                        <h3>联系人信息:</h3>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label ><span style="color: red;">*</span>联系人姓名</label>
                                            <input type="text" id="contactName" name="contactName">
                                            <span style="color:red;" id="contactNames"></span>
                                        </div>
                                    </div>
                                    <div class="form-row">
                                        <div class="form-group col-md-12">
                                            <label ><span style="color: red;">*</span>联系人电话</label>
                                            <input type="text" id="contactNumber" name="contactNumber">
                                            <span style="color:red;" id="contactNumbers"></span>
                                        </div>
                                    </div>
                                    <button type="submit" class="btn btn-primary job-post-btn btn-lg btn-block ">发布</button>
                                </form>
                                </c:if>

                                <c:if test="${not result}">
                                    <form id="form" action="<%=path%>/web/information/updateByInformationId1" method="post" enctype="multipart/form-data">
                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label for="jobname">&nbsp;求助者姓名</label>
                                                <input type="text" name="name" class="#" id="jobname" value="${requestScope.information.name}">
                                                <input type="hidden" value="${requestScope.information.lostTypeId}" name="lostTypeId">
                                                <input type="hidden" value="${requestScope.information.id}" name="id">
                                                <span id="nameStyle"></span>
                                            </div>
                                        </div>
                                            <%-- <div class="form-row">
                                                 <div class="form-group col-md-12">
                                                     <label for="jobname">联系人姓名</label>
                                                     <input type="text" name="name" class="#" id="contactName" value="">
                                                     <span id="contactNames"></span>
                                                 </div>
                                             </div>--%>

                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label for="jobname"><span style="color: red;">*</span>求助者身高</label>
                                                <input type="text" id="high" name="lostHeight" value="${requestScope.information.lostHeight}">（cm）
                                                <span style="color:red;" id="highs"></span>
                                            </div>
                                        </div>
                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label for="jobname"><span style="color: red;">*</span>求助者体重</label>
                                                <input type="text" id="weight" name="lostWeight" value="${requestScope.information.lostWeight}">（kg）
                                                <span style="color:red;" id="weights"></span>
                                            </div>
                                        </div>
                                        <div class="form-row">
                                            <div  class="form-group col-md-12">
                                                <label style="float: left;"><span style="color: red;">*</span>年龄范围</label>
                                                <select id="ageStart"  class="form-control custom-select" style="width:60px;margin-left: 10px; " name="ageStart">
                                                    <c:forEach begin="1" end="100" varStatus="stat">
                                                        <c:if test="${requestScope.information.ageStart eq stat.index}" var="age">
                                                        <option selected>${stat.index}</option>
                                                        </c:if>
                                                        <c:if test="${not age}">
                                                            <option>${stat.index}</option>
                                                        </c:if>
                                                    </c:forEach>
                                                </select>
                                                <span style="position: absolute;left:158px;">到</span>
                                                <select id="ageEnd" class="form-control custom-select" style="width:60px;margin-left: 10px; " name="ageEnd">
                                                    <c:forEach begin="1" end="100" varStatus="stat">
                                                        <c:if test="${requestScope.information.ageEnd eq stat.index}" var="age1">
                                                            <option selected>${stat.index}</option>
                                                        </c:if>
                                                        <c:if test="${not age1}">
                                                            <option>${stat.index}</option>
                                                        </c:if>
                                                    </c:forEach>
                                                </select>
                                                <span id="ages" style="position: absolute;left:250px;">（知道具体年龄请前后一致）</span>
                                            </div>

                                        </div>
                                        <div class="form-row" style="margin-top: 0px;">
                                            <div>
                                                <div class="form-group col-md-12">
                                                    <label style="margin-left: -10px;" ><span style="color: red;">*</span>发现时间</label>
                                                    <input type="date" id="begindate" name="lostDateStart" value="${requestScope.information.lostDateStart}">
                                                    <span id="begindates"></span>
                                                </div>
                                            </div>

                                        </div>

                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label for="jobname"><span style="color: red;">*</span>选择性别</label>
                                                <c:if test="${requestScope.information.sex eq '男'}">
                                                    <INPUT checked name="sex" type="radio" value="男"/>男
                                                    <INPUT name="sex" type="radio" value="女"/>女
                                                </c:if>
                                                <c:if test="${requestScope.information.sex eq '女'}">
                                                    <INPUT name="sex" type="radio" value="男"/>男
                                                    <INPUT checked name="sex" type="radio" value="女"/>女
                                                </c:if>
                                            </div>
                                        </div>
                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label for="jobname">&nbsp;选择血型</label>
                                                <c:if test="${requestScope.information.blood eq NULL}">
                                                    <INPUT name="blood" type="radio" value="A"/>A型
                                                    <INPUT name="blood" type="radio" value="B"/>B型
                                                    <INPUT name="blood" type="radio" value="AB"/>AB型
                                                    <INPUT name="blood" type="radio" value="O"/>O型
                                                    <INPUT name="blood" type="radio" value="其它"/>其它
                                                </c:if>
                                                <c:if test="${requestScope.information.blood eq 'A'}">
                                                    <INPUT checked name="blood" type="radio" value="A"/>A型
                                                    <INPUT name="blood" type="radio" value="B"/>B型
                                                    <INPUT name="blood" type="radio" value="AB"/>AB型
                                                    <INPUT name="blood" type="radio" value="O"/>O型
                                                    <INPUT name="blood" type="radio" value="其它"/>其它
                                                </c:if>
                                                <c:if test="${requestScope.information.blood eq 'B'}">
                                                    <INPUT name="blood" type="radio" value="A"/>A型
                                                    <INPUT checked name="blood" type="radio" value="B"/>B型
                                                    <INPUT name="blood" type="radio" value="AB"/>AB型
                                                    <INPUT name="blood" type="radio" value="O"/>O型
                                                    <INPUT name="blood" type="radio" value="其它"/>其它
                                                </c:if>
                                                <c:if test="${requestScope.information.blood eq 'AB'}">
                                                    <INPUT name="blood" type="radio" value="A"/>A型
                                                    <INPUT name="blood" type="radio" value="B"/>B型
                                                    <INPUT checked name="blood" type="radio" value="AB"/>AB型
                                                    <INPUT name="blood" type="radio" value="O"/>O型
                                                    <INPUT name="blood" type="radio" value="其它"/>其它
                                                </c:if>
                                                <c:if test="${requestScope.information.blood eq 'O'}">
                                                    <INPUT name="blood" type="radio" value="A"/>A型
                                                    <INPUT name="blood" type="radio" value="B"/>B型
                                                    <INPUT name="blood" type="radio" value="AB"/>AB型
                                                    <INPUT checked name="blood" type="radio" value="O"/>O型
                                                    <INPUT name="blood" type="radio" value="其它"/>其它
                                                </c:if>
                                                <c:if test="${requestScope.information.blood eq '其他'}">
                                                    <INPUT name="blood" type="radio" value="A"/>A型
                                                    <INPUT name="blood" type="radio" value="B"/>B型
                                                    <INPUT name="blood" type="radio" value="AB"/>AB型
                                                    <INPUT name="blood" type="radio" value="O"/>O型
                                                    <INPUT checked name="blood" type="radio" value="其它"/>其它
                                                </c:if>
                                            </div>
                                        </div>
                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label style="float: left; " for="jobname"><span style="color: red;">*</span>上传图片</label>
                                                <input style="float: left;padding-left: 5px;" type="file" id="pic" name="pic1"/>
                                                <span id="pics"></span>
                                            </div>
                                        </div>
                                        <!-- 显示图片的DIV-->
                                        <div style="border:1px solid black; width: 250px;height:200px;margin-bottom: 10px;">
                                            <img style="width: 248px;height: 198px;" id="showPic" src="<%=path %>/web/uploadImages/${information.pic}">
                                        </div>
                                        <!-- /显示图片的DIV-->

                                        <div class="form-row">
                                            <div  class="form-group col-md-12">
                                                <label style="float: left;">&nbsp;籍贯</label>
                                                <select id="province" class="form-control custom-select" style="width:150px;float: left;margin-left: 10px; " name="provinceId">
                                                    <c:forEach items="${requestScope.provinces}" var="province">
                                                        <c:if test="${province.areaId eq requestScope.provinceId}" var="province1">
                                                            <option value="${province.areaId}" selected>${province.areaName}</option>
                                                        </c:if>
                                                        <c:if test="${not province1}">
                                                            <option value="${province.areaId}">${province.areaName}</option>
                                                        </c:if>
                                                    </c:forEach>
                                                </select>
                                                <select data-id="${requestScope.information.cityId}" id="city" name="cityId " class="form-control custom-select" style="width:150px; float: left;">
                                                </select>
                                                <select data-id="${requestScope.information.areaId}" id="area" name="areaId" class="form-control custom-select" style="width:150px;float: left ">
                                                </select>
                                                <p style="float: left;">(未知可选不详)</p>
                                            </div>
                                        </div>

                                        <div class="form-row">
                                            <label>&nbsp;现居地</label>
                                            <textarea  name="presentAddress"class="form-control" id="jobDescription" rows="3">${requestScope.information.presentAddress}</textarea>
                                            <span style="color: red" id="live"></span>
                                        </div>
                                        <div class="form-row">
                                            <label >&nbsp;发现地点</label>
                                            <textarea name="findPlace" class="form-control" id="lostPlace" rows="3">${requestScope.information.findPlace}</textarea>
                                            <span style="color: red" id="lostplaces"></span>
                                        </div>
                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label for="jobDescription">&nbsp;备注(其他需要填写的信息)</label>
                                                <textarea name="lostRemark" class="form-control" id="jobDescription1" rows="3">${requestScope.information.lostRemark}</textarea>
                                                <span id="family"></span>
                                            </div>
                                        </div>
                                        <div class="info-title mb-3">
                                            <h3>联系人信息:</h3>
                                        </div>
                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label ><span style="color: red;">*</span>联系人姓名</label>
                                                <input type="text" id="contactName" name="contactName" value="${requestScope.information.contactName}">
                                                <span style="color:red;" id="contactNames"></span>
                                            </div>
                                        </div>
                                        <div class="form-row">
                                            <div class="form-group col-md-12">
                                                <label ><span style="color: red;">*</span>联系人电话</label>
                                                <input type="text" id="contactNumber" name="contactNumber" value="${requestScope.information.contactNumber}">
                                                <span style="color:red;" id="contactNumbers"></span>
                                            </div>
                                        </div>
                                        <button type="submit" class="btn btn-primary job-post-btn btn-lg btn-block ">发布</button>
                                    </form>
                                </c:if>
                            </div>
                        </div>

                    </div>
                </div>
            </div>
        </div>
    </div>
</main>
<!--footer-area-start -->
<footer>
    <div class="footer" style="height: 230px;">
        <div class="container" style="margin-top: -40px;">
            <p style="font-size: 15px;"><span style="font-size: 20px;">等你回家</span><span >邮箱:1111111@163.com</span> 电话:0532—85025005</p>
            <p class="footer-class" style="font-size:15px;margin-top: -75px;">地址:山东省青岛市市南区中联创意广场B1栋三楼 <a href="http://w3layouts.com/" target="_blank">万码学堂</a></p>
            <p class="footer-class" style="font-size:15px;margin-top: -60px;text-transform: none;">Copyright © 2019 www.dengnihuijia.com All rights Reserved.</p>
        </div>
    </div>
</footer>
<script src="<%=path%>/web/static/js/modules/jquery-3.4.1.min.js"></script>
</body>
</html>
<script type="text/javascript">
    $(function () {

        <!-- 图片上传加显示-->
        var input=document.getElementById("pic");
        input.onchange = function() {
            var rd = new FileReader();//创建文件读取对象
            var files = input.files[0];//获取file组件中的文件
            rd.readAsDataURL(files);//文件读取装换为base64类型
            rd.onloadend = function (e) {
                //加载完毕之后获取结果赋值给img
                document.getElementById("showPic").src = this.result;
            }
        }
        <!-- /图片上传加显示-->

        var error_high = false;//身高
        var error_time = false;//判断发现时间
        var error_weight=false;//体重

        var error_age=false;//年龄范围;
        var error_image=false;//头像;
        var error_contactName=false;//联系人姓名；
        var error_contactNumber=false;//联系人电话;



        $("#begindate").blur(function () {//判断发现时间失去焦点
            check_time();
        })
        $("#weight").blur(function () {//体重失去焦点事件
            check_weight();
        })
        $("#high").blur(function () {//身高失去焦点事件
            check_user_high1();
        })


        $("#ageStart").change(function () {//年龄范围失去焦点事件
            check_age();
        })
        $("#ageEnd").change(function () {//年龄范围失去焦点事件
            check_age();
        })

        $("#pic").blur(function () {//上传图片失去焦点事件
            check_pic();
        })


        $("#contactName").blur(function () {//联系人姓名失去焦点事件
            check_contactName();
        })
        $("#contactNumber").blur(function () {//联系人电话失去焦点事件
            check_contactNumber();
        })

        function check_weight() {//体重
            var weight=$("#weight").val();
           var zz=/^[1-9]\d{0,2}(\.\d{0,3})?$/;
            var flag=zz.test(weight);
           if(flag)
           {
               error_weight=false;
               $("#weights").html("");
           }
           else{
               error_weight=true;
               $("#weights").html("（请输入正确格式kg）");
           }
        }
       /* function check_user_name() {//判断姓名获得焦点事件
            $("#jobname").next().html("(2-7位中文)");
            $("#nameStyle").css("color", "green");
            $('#jobname').next().show();
        }*/
      /*  function check_user_high() {//身高得到焦点事件
            $("#high").next().html("(2-3位阿拉伯数字)");
            $("#highs").css("color", "green")
            $('#high').next().show();
        }*/

        function check_user_high1() {//身高失去焦点事件
            var rs = /^[1-9]\d{1,2}$/;
            var high = $("#high").val();
            if (high =="") {
                $("#highs").html("(身高不能为空)");
                $("#highs").css("color", "red")
                error_high = true;
            } else {
                if (rs.test(high)) {
                    $("#high").next().hide();
                    error_high = false;
                } else {
                    $("#high").next().html("(身高格式不正确)");
                    $("#highs").css("color", "red")
                    $('#high').next().show();
                    error_high = true;
                }
            }

        }


        function check_time() {//发现时间判断
            var time = $("#begindate").val();
            if (time == "") {
                $("#begindates").html("(发现时间不能为空)");
                $("#begindates").css("color","red");
                error_time = true;
            }
            else{
                $("#begindates").html("");
                error_time = false;
            }
        }


        function check_age() {//年龄范围static
            var ageStart = $("#ageStart").val();
            var ageEnd=$("#ageEnd").val();
            if (ageStart>ageEnd) {
                $("#ages").html("(年龄范围错误，请重新填写)");
                $("#ages").css("color","red");
                error_age = true;
            }
            else{
                $("#ages").html("");
                error_age = false;
            }
        }



        /*function check_user_place1() {//走失地失去焦点事件
            var place = $("#lostPlace").val();
            if (place =="") {
                $("#lostplaces").html("(走失地不能为空)");
                error_lostPlace = true;
            }
            else {
                $("#lostplaces").html("");
                error_lostPlace = false;
            }
        }*/

        function check_pic() {//图片消失焦点事件
            var pic = $("#pic").val();
            if (pic == "") {
                $("#pics").html("(图片不能为空)");
                $("#pics").css("color","red");
                error_pic = true;
            }
            else{
                $("#pics").html("");
                error_pic = false;
            }
        }
        function check_contactName() {//联系人姓名失去焦点事件
            var contactName=$("#contactName").val();
            if(contactName=="")
            {
                $("#contactNames").html("(联系人不能为空)");
                $("#contactNames").css("color","red");
                error_contactName=true;
            }
            else{
                $("#contactNames").html("");
                error_contactName=false;
            }

        }
        function check_contactNumber() {//联系人电话失去焦点事件
            var contactNumber=$("#contactNumber").val();
            var zz=/^1[34578]\d{9}$/;
            if(contactNumber=="")
            {
                $("#contactNumbers").html("(联系电话不能为空)");
                $("#contactNumbers").css("color","red");
                error_contactName=true;
            }
            else if(!zz.test(contactNumber)){
                $("#contactNumbers").html("(手机号格式错误)");
                error_contactName=true;
            }
            else{
                $("#contactNumbers").html("");
                error_contactName=false;
            }

        }


        $("#form").submit(function () {
            check_weight();
            check_age()
            check_contactName();
            check_contactNumber()
            check_pic()
            check_time()
            check_user_high1()
            if (error_weight==false &&  error_age == false && error_contactName == false && error_contactNumber == false && error_pic ==false && error_time == false && error_high==false) {
                return true;
            } else {
                return false;
            }
        })

        initCities();
        $("#province").change(function(){
            initCities()
        })
        $("#city").change(function(){
            initAreas()
        })

    })
    function initCities(){
        var provinceId = $("#province").val();
        $("#city").empty();
        $("#area").empty();
        var cityId = $("#cityId").data("id");
        var areaId = $("#areaId").data("id");
        $.ajax({
            url: "${pageContext.request.contextPath}/web/information/cities",
            data:{"areaId":provinceId},
            type:"get",
            dataType:"json",
            success:function(cities) {
                if(cityId==0&&areaId==0) {
                    for(var i=0;i<cities.length;i++)
                    {
                        $("#city").append("<option value=\""+cities[i].areaId+"\">"+cities[i].areaName+"</option>")
                    }
                    $.getJSON("${pageContext.request.contextPath}/web/information/cities",{areaId:$("#city").val()}, function (cities) {
                        for(var i=0;i<cities.length;i++)
                        {
                            $("#area").append("<option value=\""+cities[i].areaId+"\">"+cities[i].areaName+"</option>")
                        }
                    });
                }else{
                    for(var i=0;i<cities.length;i++)
                    {
                        if(cityId==cities[i].areaId){
                            $("#city").append("<option selected value=\""+cities[i].areaId+"\">"+cities[i].areaName+"</option>")
                        }else{
                            $("#city").append("<option value=\""+cities[i].areaId+"\">"+cities[i].areaName+"</option>")
                        }

                    }
                    $.getJSON("${pageContext.request.contextPath}/web/information/cities",{areaId:$("#city").val()}, function (cities) {
                        for(var i=0;i<cities.length;i++)
                        {
                            if(areaId==cities[i].areaId){
                                $("#area").append("<option selected value=\""+cities[i].areaId+"\">"+cities[i].areaName+"</option>")
                            }else{
                                $("#area").append("<option value=\""+cities[i].areaId+"\">"+cities[i].areaName+"</option>")
                            }

                        }
                    });
                }

            }
        });
    }
    function initAreas() {
        var areaId = $("#city").val();
        $("#area").empty();
        $.ajax({
            url:"${pageContext.request.contextPath}/web/information/cities",
            data:{"areaId":areaId},type:"get",dateType:"json",
            success:function (mes) {
                for (var i = 0; i < mes.length; i++) {
                    $("#area").append("<option value=\"" + mes[i].areaId + "\">" + mes[i].areaName + "</option>")
                }
            }
        })
    }

</script>

